CK_RV CK_C_Initialize(CK_VOID_PTR pReserved) {
	#ifdef DEBUG
	printf("CK_C_Initialize\n");
	fflush(stdout);
	#endif
	R_CK_C_Initialize_Param in;
	// Wrapping
	in.pReserved = (void*) pReserved;
	// End Wrapping
	//Remote calling
	R_CK_C_Initialize_Param *out = r_ck_c_initialize_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Initialize.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	if (pReserved != NULL && out->pReserved != NULL) {
		memcpy(pReserved, out->pReserved, sizeof(int));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Finalize(CK_VOID_PTR pReserved) {
	#ifdef DEBUG
	printf("CK_C_Finalize\n");
	fflush(stdout);
	#endif
	R_CK_C_Finalize_Param in;
	// Wrapping
	in.pReserved = (void*) pReserved;
	// End Wrapping
	//Remote calling
	R_CK_C_Finalize_Param *out = r_ck_c_finalize_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Finalize.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Terminate() {
	#ifdef DEBUG
	printf("CK_C_Terminate\n");
	fflush(stdout);
	#endif
	R_CK_C_Terminate_Param in;
	// Wrapping
	// End Wrapping
	//Remote calling
	R_CK_C_Terminate_Param *out = r_ck_c_terminate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Terminate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetInfo(CK_INFO_PTR pInfo) {
	#ifdef DEBUG
	printf("CK_C_GetInfo\n");
	fflush(stdout);
	#endif
	R_CK_C_GetInfo_Param in;
	// Wrapping
	in.pInfo = malloc(sizeof(REMOTE_CK_INFO));
	in.pInfo->cryptokiVersion.major = pInfo->cryptokiVersion.major;
	in.pInfo->cryptokiVersion.minor = pInfo->cryptokiVersion.minor;
	memcpy(in.pInfo->manufacturerID, pInfo->manufacturerID, 32);
	in.pInfo->flags = pInfo->flags;
	memcpy(in.pInfo->libraryDescription, pInfo->libraryDescription, 32);
	in.pInfo->libraryVersion.major = pInfo->libraryVersion.major;
	in.pInfo->libraryVersion.minor = pInfo->libraryVersion.minor;
	// End Wrapping
	//Remote calling
	R_CK_C_GetInfo_Param *out = r_ck_c_getinfo_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetInfo.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pInfo != NULL) {
	}
	free(in.pInfo);
	in.pInfo = NULL;
	// End Free Wrapping
	// Unwrapping
	if (pInfo != NULL && out->pInfo != NULL) {
		pInfo->cryptokiVersion.major = out->pInfo->cryptokiVersion.major;
		pInfo->cryptokiVersion.minor = out->pInfo->cryptokiVersion.minor;
		memcpy(pInfo->manufacturerID, out->pInfo->manufacturerID, 32);
		pInfo->flags = out->pInfo->flags;
		memcpy(pInfo->libraryDescription, out->pInfo->libraryDescription, 32);
		pInfo->libraryVersion.major = out->pInfo->libraryVersion.major;
		pInfo->libraryVersion.minor = out->pInfo->libraryVersion.minor;
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetSlotList(CK_BBOOL tokenPresent, CK_SLOT_ID_PTR pSlotList, CK_ULONG_PTR pusCount) {
	#ifdef DEBUG
	printf("CK_C_GetSlotList\n");
	fflush(stdout);
	#endif
	R_CK_C_GetSlotList_Param in;
	// Wrapping
	in.tokenPresent = tokenPresent;
	if (pSlotList == NULL) {
		in.pSlotList.pSlotList_val = NULL;
		in.pSlotList.pSlotList_len = 0;
	}
	else {
		in.pSlotList.pSlotList_val = malloc(sizeof(REMOTE_CK_SLOT_ID) * (*pusCount));
		memcpy(in.pSlotList.pSlotList_val, pSlotList, sizeof(CK_SLOT_ID) * (*pusCount));
		in.pSlotList.pSlotList_len = (*pusCount);
	}
	in.pusCount = (void*) pusCount;
	// End Wrapping
	//Remote calling
	R_CK_C_GetSlotList_Param *out = r_ck_c_getslotlist_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetSlotList.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pSlotList.pSlotList_val);
	in.pSlotList.pSlotList_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pSlotList.pSlotList_len != 0) {
		memcpy(pSlotList, out->pSlotList.pSlotList_val, sizeof(CK_ULONG) * out->pSlotList.pSlotList_len);
	}
	if (pusCount != NULL && out->pusCount != NULL) {
		memcpy(pusCount, out->pusCount, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo) {
	#ifdef DEBUG
	printf("CK_C_GetSlotInfo\n");
	fflush(stdout);
	#endif
	R_CK_C_GetSlotInfo_Param in;
	// Wrapping
	in.slotID = slotID;
	in.pInfo = malloc(sizeof(REMOTE_CK_SLOT_INFO));
	memcpy(in.pInfo->slotDescription, pInfo->slotDescription, 64);
	memcpy(in.pInfo->manufacturerID, pInfo->manufacturerID, 32);
	in.pInfo->flags = pInfo->flags;
	in.pInfo->hardwareVersion.major = pInfo->hardwareVersion.major;
	in.pInfo->hardwareVersion.minor = pInfo->hardwareVersion.minor;
	in.pInfo->firmwareVersion.major = pInfo->firmwareVersion.major;
	in.pInfo->firmwareVersion.minor = pInfo->firmwareVersion.minor;
	// End Wrapping
	//Remote calling
	R_CK_C_GetSlotInfo_Param *out = r_ck_c_getslotinfo_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetSlotInfo.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pInfo != NULL) {
	}
	free(in.pInfo);
	in.pInfo = NULL;
	// End Free Wrapping
	// Unwrapping
	if (pInfo != NULL && out->pInfo != NULL) {
		memcpy(pInfo->slotDescription, out->pInfo->slotDescription, 64);
		memcpy(pInfo->manufacturerID, out->pInfo->manufacturerID, 32);
		pInfo->flags = out->pInfo->flags;
		pInfo->hardwareVersion.major = out->pInfo->hardwareVersion.major;
		pInfo->hardwareVersion.minor = out->pInfo->hardwareVersion.minor;
		pInfo->firmwareVersion.major = out->pInfo->firmwareVersion.major;
		pInfo->firmwareVersion.minor = out->pInfo->firmwareVersion.minor;
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetTokenInfo(CK_SLOT_ID slotID, CK_TOKEN_INFO_PTR pInfo) {
	#ifdef DEBUG
	printf("CK_C_GetTokenInfo\n");
	fflush(stdout);
	#endif
	R_CK_C_GetTokenInfo_Param in;
	// Wrapping
	in.slotID = slotID;
	in.pInfo = malloc(sizeof(REMOTE_CK_TOKEN_INFO));
	memcpy(in.pInfo->label, pInfo->label, 32);
	memcpy(in.pInfo->manufacturerID, pInfo->manufacturerID, 32);
	memcpy(in.pInfo->model, pInfo->model, 16);
	memcpy(in.pInfo->serialNumber, pInfo->serialNumber, 16);
	in.pInfo->flags = pInfo->flags;
	in.pInfo->ulMaxSessionCount = pInfo->ulMaxSessionCount;
	in.pInfo->ulSessionCount = pInfo->ulSessionCount;
	in.pInfo->ulMaxRwSessionCount = pInfo->ulMaxRwSessionCount;
	in.pInfo->ulRwSessionCount = pInfo->ulRwSessionCount;
	in.pInfo->ulMaxPinLen = pInfo->ulMaxPinLen;
	in.pInfo->ulMinPinLen = pInfo->ulMinPinLen;
	in.pInfo->ulTotalPublicMemory = pInfo->ulTotalPublicMemory;
	in.pInfo->ulFreePublicMemory = pInfo->ulFreePublicMemory;
	in.pInfo->ulTotalPrivateMemory = pInfo->ulTotalPrivateMemory;
	in.pInfo->ulFreePrivateMemory = pInfo->ulFreePrivateMemory;
	in.pInfo->hardwareVersion.major = pInfo->hardwareVersion.major;
	in.pInfo->hardwareVersion.minor = pInfo->hardwareVersion.minor;
	in.pInfo->firmwareVersion.major = pInfo->firmwareVersion.major;
	in.pInfo->firmwareVersion.minor = pInfo->firmwareVersion.minor;
	memcpy(in.pInfo->utcTime, pInfo->utcTime, 16);
	// End Wrapping
	//Remote calling
	R_CK_C_GetTokenInfo_Param *out = r_ck_c_gettokeninfo_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetTokenInfo.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pInfo != NULL) {
	}
	free(in.pInfo);
	in.pInfo = NULL;
	// End Free Wrapping
	// Unwrapping
	if (pInfo != NULL && out->pInfo != NULL) {
		memcpy(pInfo->label, out->pInfo->label, 32);
		memcpy(pInfo->manufacturerID, out->pInfo->manufacturerID, 32);
		memcpy(pInfo->model, out->pInfo->model, 16);
		memcpy(pInfo->serialNumber, out->pInfo->serialNumber, 16);
		pInfo->flags = out->pInfo->flags;
		pInfo->ulMaxSessionCount = out->pInfo->ulMaxSessionCount;
		pInfo->ulSessionCount = out->pInfo->ulSessionCount;
		pInfo->ulMaxRwSessionCount = out->pInfo->ulMaxRwSessionCount;
		pInfo->ulRwSessionCount = out->pInfo->ulRwSessionCount;
		pInfo->ulMaxPinLen = out->pInfo->ulMaxPinLen;
		pInfo->ulMinPinLen = out->pInfo->ulMinPinLen;
		pInfo->ulTotalPublicMemory = out->pInfo->ulTotalPublicMemory;
		pInfo->ulFreePublicMemory = out->pInfo->ulFreePublicMemory;
		pInfo->ulTotalPrivateMemory = out->pInfo->ulTotalPrivateMemory;
		pInfo->ulFreePrivateMemory = out->pInfo->ulFreePrivateMemory;
		pInfo->hardwareVersion.major = out->pInfo->hardwareVersion.major;
		pInfo->hardwareVersion.minor = out->pInfo->hardwareVersion.minor;
		pInfo->firmwareVersion.major = out->pInfo->firmwareVersion.major;
		pInfo->firmwareVersion.minor = out->pInfo->firmwareVersion.minor;
		memcpy(pInfo->utcTime, out->pInfo->utcTime, 16);
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetMechanismList(CK_SLOT_ID slotID, CK_MECHANISM_TYPE_PTR pMechanismList, CK_ULONG_PTR pusCount) {
	#ifdef DEBUG
	printf("CK_C_GetMechanismList\n");
	fflush(stdout);
	#endif
	R_CK_C_GetMechanismList_Param in;
	// Wrapping
	in.slotID = slotID;
	if (pMechanismList == NULL) {
		in.pMechanismList.pMechanismList_val = NULL;
		in.pMechanismList.pMechanismList_len = 0;
	}
	else {
		in.pMechanismList.pMechanismList_val = malloc(sizeof(REMOTE_CK_MECHANISM_TYPE) * (*pusCount));
		memcpy(in.pMechanismList.pMechanismList_val, pMechanismList, sizeof(CK_MECHANISM_TYPE) * (*pusCount));
		in.pMechanismList.pMechanismList_len = (*pusCount);
	}
	in.pusCount = (void*) pusCount;
	// End Wrapping
	//Remote calling
	R_CK_C_GetMechanismList_Param *out = r_ck_c_getmechanismlist_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetMechanismList.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pMechanismList.pMechanismList_val);
	in.pMechanismList.pMechanismList_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pMechanismList.pMechanismList_len != 0) {
		memcpy(pMechanismList, out->pMechanismList.pMechanismList_val, sizeof(CK_ULONG) * out->pMechanismList.pMechanismList_len);
	}
	if (pusCount != NULL && out->pusCount != NULL) {
		memcpy(pusCount, out->pusCount, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetMechanismInfo(CK_SLOT_ID slotID, CK_MECHANISM_TYPE type, CK_MECHANISM_INFO_PTR pInfo) {
	#ifdef DEBUG
	printf("CK_C_GetMechanismInfo\n");
	fflush(stdout);
	#endif
	R_CK_C_GetMechanismInfo_Param in;
	// Wrapping
	in.slotID = slotID;
	in.type = type;
	in.pInfo = malloc(sizeof(REMOTE_CK_MECHANISM_INFO));
	in.pInfo->ulMinKeySize = pInfo->ulMinKeySize;
	in.pInfo->ulMaxKeySize = pInfo->ulMaxKeySize;
	in.pInfo->flags = pInfo->flags;
	// End Wrapping
	//Remote calling
	R_CK_C_GetMechanismInfo_Param *out = r_ck_c_getmechanisminfo_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetMechanismInfo.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pInfo != NULL) {
	}
	free(in.pInfo);
	in.pInfo = NULL;
	// End Free Wrapping
	// Unwrapping
	if (pInfo != NULL && out->pInfo != NULL) {
		pInfo->ulMinKeySize = out->pInfo->ulMinKeySize;
		pInfo->ulMaxKeySize = out->pInfo->ulMaxKeySize;
		pInfo->flags = out->pInfo->flags;
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_InitToken(CK_SLOT_ID slotID, CK_CHAR_PTR pPin, CK_ULONG usPinLen, CK_CHAR_PTR pLabel) {
	#ifdef DEBUG
	printf("CK_C_InitToken\n");
	fflush(stdout);
	#endif
	R_CK_C_InitToken_Param in;
	// Wrapping
	in.slotID = slotID;
	if (pPin == NULL) {
		in.pPin.pPin_val = NULL;
		in.pPin.pPin_len = 0;
	}
	else {
		in.pPin.pPin_val = malloc(sizeof(REMOTE_CK_CHAR) * usPinLen);
		memcpy(in.pPin.pPin_val, pPin, sizeof(CK_CHAR) * usPinLen);
		in.pPin.pPin_len = usPinLen;
	}
	in.usPinLen = usPinLen;
	if (pLabel == NULL) {
		in.pLabel.pLabel_val = NULL;
		in.pLabel.pLabel_len = 0;
	}
	else {
		in.pLabel.pLabel_val = malloc(sizeof(REMOTE_CK_CHAR) * 32);
		memcpy(in.pLabel.pLabel_val, pLabel, sizeof(CK_CHAR) * 32);
		in.pLabel.pLabel_len = 32;
	}
	// End Wrapping
	//Remote calling
	R_CK_C_InitToken_Param *out = r_ck_c_inittoken_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_InitToken.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPin.pPin_val);
	in.pPin.pPin_val = NULL;
	free(in.pLabel.pLabel_val);
	in.pLabel.pLabel_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_InitPIN(CK_SESSION_HANDLE hSession, CK_CHAR_PTR pPin, CK_ULONG usPinLen) {
	#ifdef DEBUG
	printf("CK_C_InitPIN\n");
	fflush(stdout);
	#endif
	R_CK_C_InitPIN_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPin == NULL) {
		in.pPin.pPin_val = NULL;
		in.pPin.pPin_len = 0;
	}
	else {
		in.pPin.pPin_val = malloc(sizeof(REMOTE_CK_CHAR) * usPinLen);
		memcpy(in.pPin.pPin_val, pPin, sizeof(CK_CHAR) * usPinLen);
		in.pPin.pPin_len = usPinLen;
	}
	in.usPinLen = usPinLen;
	// End Wrapping
	//Remote calling
	R_CK_C_InitPIN_Param *out = r_ck_c_initpin_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_InitPIN.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPin.pPin_val);
	in.pPin.pPin_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SetPIN(CK_SESSION_HANDLE hSession, CK_CHAR_PTR pOldPin, CK_ULONG usOldLen, CK_CHAR_PTR pNewPin, CK_ULONG usNewLen) {
	#ifdef DEBUG
	printf("CK_C_SetPIN\n");
	fflush(stdout);
	#endif
	R_CK_C_SetPIN_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pOldPin == NULL) {
		in.pOldPin.pOldPin_val = NULL;
		in.pOldPin.pOldPin_len = 0;
	}
	else {
		in.pOldPin.pOldPin_val = malloc(sizeof(REMOTE_CK_CHAR) * usOldLen);
		memcpy(in.pOldPin.pOldPin_val, pOldPin, sizeof(CK_CHAR) * usOldLen);
		in.pOldPin.pOldPin_len = usOldLen;
	}
	in.usOldLen = usOldLen;
	if (pNewPin == NULL) {
		in.pNewPin.pNewPin_val = NULL;
		in.pNewPin.pNewPin_len = 0;
	}
	else {
		in.pNewPin.pNewPin_val = malloc(sizeof(REMOTE_CK_CHAR) * usNewLen);
		memcpy(in.pNewPin.pNewPin_val, pNewPin, sizeof(CK_CHAR) * usNewLen);
		in.pNewPin.pNewPin_len = usNewLen;
	}
	in.usNewLen = usNewLen;
	// End Wrapping
	//Remote calling
	R_CK_C_SetPIN_Param *out = r_ck_c_setpin_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SetPIN.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pOldPin.pOldPin_val);
	in.pOldPin.pOldPin_val = NULL;
	free(in.pNewPin.pNewPin_val);
	in.pNewPin.pNewPin_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_OpenSession(CK_SLOT_ID slotID, CK_FLAGS flags, CK_VOID_PTR pApplication, CK_VOID_PTR notify, CK_SESSION_HANDLE_PTR phSession) {
	#ifdef DEBUG
	printf("CK_C_OpenSession\n");
	fflush(stdout);
	#endif
	R_CK_C_OpenSession_Param in;
	// Wrapping
	in.slotID = slotID;
	in.flags = flags;
	in.pApplication = (void*) pApplication;
	in.notify = (void*) notify;
	in.phSession = (void*) phSession;
	// End Wrapping
	//Remote calling
	R_CK_C_OpenSession_Param *out = r_ck_c_opensession_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_OpenSession.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	if (phSession != NULL && out->phSession != NULL) {
		memcpy(phSession, out->phSession, sizeof(CK_SESSION_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_CloseSession(CK_SESSION_HANDLE hSession) {
	#ifdef DEBUG
	printf("CK_C_CloseSession\n");
	fflush(stdout);
	#endif
	R_CK_C_CloseSession_Param in;
	// Wrapping
	in.hSession = hSession;
	// End Wrapping
	//Remote calling
	R_CK_C_CloseSession_Param *out = r_ck_c_closesession_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_CloseSession.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_CloseAllSessions(CK_SLOT_ID slotID) {
	#ifdef DEBUG
	printf("CK_C_CloseAllSessions\n");
	fflush(stdout);
	#endif
	R_CK_C_CloseAllSessions_Param in;
	// Wrapping
	in.slotID = slotID;
	// End Wrapping
	//Remote calling
	R_CK_C_CloseAllSessions_Param *out = r_ck_c_closeallsessions_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_CloseAllSessions.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetSessionInfo(CK_SESSION_HANDLE hSession, CK_SESSION_INFO_PTR pInfo) {
	#ifdef DEBUG
	printf("CK_C_GetSessionInfo\n");
	fflush(stdout);
	#endif
	R_CK_C_GetSessionInfo_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pInfo = malloc(sizeof(REMOTE_CK_SESSION_INFO));
	in.pInfo->slotID = pInfo->slotID;
	in.pInfo->state = pInfo->state;
	in.pInfo->flags = pInfo->flags;
	in.pInfo->ulDeviceError = pInfo->ulDeviceError;
	// End Wrapping
	//Remote calling
	R_CK_C_GetSessionInfo_Param *out = r_ck_c_getsessioninfo_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetSessionInfo.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pInfo != NULL) {
	}
	free(in.pInfo);
	in.pInfo = NULL;
	// End Free Wrapping
	// Unwrapping
	if (pInfo != NULL && out->pInfo != NULL) {
		pInfo->slotID = out->pInfo->slotID;
		pInfo->state = out->pInfo->state;
		pInfo->flags = out->pInfo->flags;
		pInfo->ulDeviceError = out->pInfo->ulDeviceError;
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetOperationState(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pOperationState, CK_ULONG_PTR pulOperationStateLen) {
	#ifdef DEBUG
	printf("CK_C_GetOperationState\n");
	fflush(stdout);
	#endif
	R_CK_C_GetOperationState_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pOperationState == NULL) {
		in.pOperationState.pOperationState_val = NULL;
		in.pOperationState.pOperationState_len = 0;
	}
	else {
		in.pOperationState.pOperationState_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pulOperationStateLen));
		memcpy(in.pOperationState.pOperationState_val, pOperationState, sizeof(CK_BYTE) * (*pulOperationStateLen));
		in.pOperationState.pOperationState_len = (*pulOperationStateLen);
	}
	in.pulOperationStateLen = (void*) pulOperationStateLen;
	// End Wrapping
	//Remote calling
	R_CK_C_GetOperationState_Param *out = r_ck_c_getoperationstate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetOperationState.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pOperationState.pOperationState_val);
	in.pOperationState.pOperationState_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pOperationState.pOperationState_len != 0) {
		memcpy(pOperationState, out->pOperationState.pOperationState_val, sizeof(char) * out->pOperationState.pOperationState_len);
	}
	if (pulOperationStateLen != NULL && out->pulOperationStateLen != NULL) {
		memcpy(pulOperationStateLen, out->pulOperationStateLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SetOperationState(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pOperationState, CK_ULONG ulOperationStateLen, CK_OBJECT_HANDLE hEncryptionKey, CK_OBJECT_HANDLE hAuthenticationKey) {
	#ifdef DEBUG
	printf("CK_C_SetOperationState\n");
	fflush(stdout);
	#endif
	R_CK_C_SetOperationState_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pOperationState == NULL) {
		in.pOperationState.pOperationState_val = NULL;
		in.pOperationState.pOperationState_len = 0;
	}
	else {
		in.pOperationState.pOperationState_val = malloc(sizeof(REMOTE_CK_BYTE) * ulOperationStateLen);
		memcpy(in.pOperationState.pOperationState_val, pOperationState, sizeof(CK_BYTE) * ulOperationStateLen);
		in.pOperationState.pOperationState_len = ulOperationStateLen;
	}
	in.ulOperationStateLen = ulOperationStateLen;
	in.hEncryptionKey = hEncryptionKey;
	in.hAuthenticationKey = hAuthenticationKey;
	// End Wrapping
	//Remote calling
	R_CK_C_SetOperationState_Param *out = r_ck_c_setoperationstate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SetOperationState.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pOperationState.pOperationState_val);
	in.pOperationState.pOperationState_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Login(CK_SESSION_HANDLE hSession, CK_USER_TYPE userType, CK_CHAR_PTR pPin, CK_ULONG usPinLen) {
	#ifdef DEBUG
	printf("CK_C_Login\n");
	fflush(stdout);
	#endif
	R_CK_C_Login_Param in;
	// Wrapping
	in.hSession = hSession;
	in.userType = userType;
	if (pPin == NULL) {
		in.pPin.pPin_val = NULL;
		in.pPin.pPin_len = 0;
	}
	else {
		in.pPin.pPin_val = malloc(sizeof(REMOTE_CK_CHAR) * usPinLen);
		memcpy(in.pPin.pPin_val, pPin, sizeof(CK_CHAR) * usPinLen);
		in.pPin.pPin_len = usPinLen;
	}
	in.usPinLen = usPinLen;
	// End Wrapping
	//Remote calling
	R_CK_C_Login_Param *out = r_ck_c_login_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Login.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPin.pPin_val);
	in.pPin.pPin_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Logout(CK_SESSION_HANDLE hSession) {
	#ifdef DEBUG
	printf("CK_C_Logout\n");
	fflush(stdout);
	#endif
	R_CK_C_Logout_Param in;
	// Wrapping
	in.hSession = hSession;
	// End Wrapping
	//Remote calling
	R_CK_C_Logout_Param *out = r_ck_c_logout_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Logout.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_CreateObject(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phObject) {
	#ifdef DEBUG
	printf("CK_C_CreateObject\n");
	fflush(stdout);
	#endif
	R_CK_C_CreateObject_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
		in.pTemplate.pTemplate_len = usCount;
	}
	in.usCount = usCount;
	in.phObject = (void*) phObject;
	// End Wrapping
	//Remote calling
	R_CK_C_CreateObject_Param *out = r_ck_c_createobject_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_CreateObject.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (phObject != NULL && out->phObject != NULL) {
		memcpy(phObject, out->phObject, sizeof(CK_OBJECT_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_CopyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phNewObject) {
	#ifdef DEBUG
	printf("CK_C_CopyObject\n");
	fflush(stdout);
	#endif
	R_CK_C_CopyObject_Param in;
	// Wrapping
	in.hSession = hSession;
	in.hObject = hObject;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
		in.pTemplate.pTemplate_len = usCount;
	}
	in.usCount = usCount;
	in.phNewObject = (void*) phNewObject;
	// End Wrapping
	//Remote calling
	R_CK_C_CopyObject_Param *out = r_ck_c_copyobject_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_CopyObject.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (phNewObject != NULL && out->phNewObject != NULL) {
		memcpy(phNewObject, out->phNewObject, sizeof(CK_OBJECT_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject) {
	#ifdef DEBUG
	printf("CK_C_DestroyObject\n");
	fflush(stdout);
	#endif
	R_CK_C_DestroyObject_Param in;
	// Wrapping
	in.hSession = hSession;
	in.hObject = hObject;
	// End Wrapping
	//Remote calling
	R_CK_C_DestroyObject_Param *out = r_ck_c_destroyobject_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DestroyObject.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetObjectSize(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ULONG_PTR pusSize) {
	#ifdef DEBUG
	printf("CK_C_GetObjectSize\n");
	fflush(stdout);
	#endif
	R_CK_C_GetObjectSize_Param in;
	// Wrapping
	in.hSession = hSession;
	in.hObject = hObject;
	in.pusSize = (void*) pusSize;
	// End Wrapping
	//Remote calling
	R_CK_C_GetObjectSize_Param *out = r_ck_c_getobjectsize_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetObjectSize.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	if (pusSize != NULL && out->pusSize != NULL) {
		memcpy(pusSize, out->pusSize, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount) {
	#ifdef DEBUG
	printf("CK_C_GetAttributeValue\n");
	fflush(stdout);
	#endif
	R_CK_C_GetAttributeValue_Param in;
	// Wrapping
	in.hSession = hSession;
	in.hObject = hObject;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
		in.pTemplate.pTemplate_len = usCount;
	}
	in.usCount = usCount;
	// End Wrapping
	//Remote calling
	R_CK_C_GetAttributeValue_Param *out = r_ck_c_getattributevalue_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetAttributeValue.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pTemplate.pTemplate_len != 0) {
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = out->pTemplate.pTemplate_val;
		unwrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount) {
	#ifdef DEBUG
	printf("CK_C_SetAttributeValue\n");
	fflush(stdout);
	#endif
	R_CK_C_SetAttributeValue_Param in;
	// Wrapping
	in.hSession = hSession;
	in.hObject = hObject;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
		in.pTemplate.pTemplate_len = usCount;
	}
	in.usCount = usCount;
	// End Wrapping
	//Remote calling
	R_CK_C_SetAttributeValue_Param *out = r_ck_c_setattributevalue_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SetAttributeValue.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount) {
	#ifdef DEBUG
	printf("CK_C_FindObjectsInit\n");
	fflush(stdout);
	#endif
	R_CK_C_FindObjectsInit_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
		in.pTemplate.pTemplate_len = usCount;
	}
	in.usCount = usCount;
	// End Wrapping
	//Remote calling
	R_CK_C_FindObjectsInit_Param *out = r_ck_c_findobjectsinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_FindObjectsInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_FindObjects(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phObject, CK_ULONG usMaxObjectCount, CK_ULONG_PTR pusObjectCount) {
	#ifdef DEBUG
	printf("CK_C_FindObjects\n");
	fflush(stdout);
	#endif
	R_CK_C_FindObjects_Param in;
	// Wrapping
	in.hSession = hSession;
	if (phObject == NULL) {
		in.phObject.phObject_val = NULL;
		in.phObject.phObject_len = 0;
	}
	else {
		in.phObject.phObject_val = malloc(sizeof(REMOTE_CK_OBJECT_HANDLE) * usMaxObjectCount);
		memcpy(in.phObject.phObject_val, phObject, sizeof(CK_OBJECT_HANDLE) * usMaxObjectCount);
		in.phObject.phObject_len = usMaxObjectCount;
	}
	in.usMaxObjectCount = usMaxObjectCount;
	in.pusObjectCount = (void*) pusObjectCount;
	// End Wrapping
	//Remote calling
	R_CK_C_FindObjects_Param *out = r_ck_c_findobjects_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_FindObjects.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.phObject.phObject_val);
	in.phObject.phObject_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->phObject.phObject_len != 0) {
		memcpy(phObject, out->phObject.phObject_val, sizeof(CK_ULONG) * out->phObject.phObject_len);
	}
	if (pusObjectCount != NULL && out->pusObjectCount != NULL) {
		memcpy(pusObjectCount, out->pusObjectCount, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_FindObjectsFinal(CK_SESSION_HANDLE hSession) {
	#ifdef DEBUG
	printf("CK_C_FindObjectsFinal\n");
	fflush(stdout);
	#endif
	R_CK_C_FindObjectsFinal_Param in;
	// Wrapping
	in.hSession = hSession;
	// End Wrapping
	//Remote calling
	R_CK_C_FindObjectsFinal_Param *out = r_ck_c_findobjectsfinal_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_FindObjectsFinal.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_EncryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_EncryptInit\n");
	fflush(stdout);
	#endif
	R_CK_C_EncryptInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_EncryptInit_Param *out = r_ck_c_encryptinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_EncryptInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Encrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG usDataLen, CK_BYTE_PTR pEncryptedData, CK_ULONG_PTR pusEncryptedDataLen) {
	#ifdef DEBUG
	printf("CK_C_Encrypt\n");
	fflush(stdout);
	#endif
	R_CK_C_Encrypt_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * usDataLen);
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * usDataLen);
		in.pData.pData_len = usDataLen;
	}
	in.usDataLen = usDataLen;
	if (pEncryptedData == NULL) {
		in.pEncryptedData.pEncryptedData_val = NULL;
		in.pEncryptedData.pEncryptedData_len = 0;
	}
	else {
		in.pEncryptedData.pEncryptedData_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusEncryptedDataLen));
		memcpy(in.pEncryptedData.pEncryptedData_val, pEncryptedData, sizeof(CK_BYTE) * (*pusEncryptedDataLen));
		in.pEncryptedData.pEncryptedData_len = (*pusEncryptedDataLen);
	}
	in.pusEncryptedDataLen = (void*) pusEncryptedDataLen;
	// End Wrapping
	//Remote calling
	R_CK_C_Encrypt_Param *out = r_ck_c_encrypt_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Encrypt.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	free(in.pEncryptedData.pEncryptedData_val);
	in.pEncryptedData.pEncryptedData_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pEncryptedData.pEncryptedData_len != 0) {
		memcpy(pEncryptedData, out->pEncryptedData.pEncryptedData_val, sizeof(char) * out->pEncryptedData.pEncryptedData_len);
	}
	if (pusEncryptedDataLen != NULL && out->pusEncryptedDataLen != NULL) {
		memcpy(pusEncryptedDataLen, out->pusEncryptedDataLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_EncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, CK_ULONG usPartLen, CK_BYTE_PTR pEncryptedPart, CK_ULONG_PTR pusEncryptedPartLen) {
	#ifdef DEBUG
	printf("CK_C_EncryptUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_EncryptUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * usPartLen);
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * usPartLen);
		in.pPart.pPart_len = usPartLen;
	}
	in.usPartLen = usPartLen;
	if (pEncryptedPart == NULL) {
		in.pEncryptedPart.pEncryptedPart_val = NULL;
		in.pEncryptedPart.pEncryptedPart_len = 0;
	}
	else {
		in.pEncryptedPart.pEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusEncryptedPartLen));
		memcpy(in.pEncryptedPart.pEncryptedPart_val, pEncryptedPart, sizeof(CK_BYTE) * (*pusEncryptedPartLen));
		in.pEncryptedPart.pEncryptedPart_len = (*pusEncryptedPartLen);
	}
	in.pusEncryptedPartLen = (void*) pusEncryptedPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_EncryptUpdate_Param *out = r_ck_c_encryptupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_EncryptUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	free(in.pEncryptedPart.pEncryptedPart_val);
	in.pEncryptedPart.pEncryptedPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pEncryptedPart.pEncryptedPart_len != 0) {
		memcpy(pEncryptedPart, out->pEncryptedPart.pEncryptedPart_val, sizeof(char) * out->pEncryptedPart.pEncryptedPart_len);
	}
	if (pusEncryptedPartLen != NULL && out->pusEncryptedPartLen != NULL) {
		memcpy(pusEncryptedPartLen, out->pusEncryptedPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_EncryptFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pLastEncryptedPart, CK_ULONG_PTR pusLastEncryptedPartLen) {
	#ifdef DEBUG
	printf("CK_C_EncryptFinal\n");
	fflush(stdout);
	#endif
	R_CK_C_EncryptFinal_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pLastEncryptedPart == NULL) {
		in.pLastEncryptedPart.pLastEncryptedPart_val = NULL;
		in.pLastEncryptedPart.pLastEncryptedPart_len = 0;
	}
	else {
		in.pLastEncryptedPart.pLastEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusLastEncryptedPartLen));
		memcpy(in.pLastEncryptedPart.pLastEncryptedPart_val, pLastEncryptedPart, sizeof(CK_BYTE) * (*pusLastEncryptedPartLen));
		in.pLastEncryptedPart.pLastEncryptedPart_len = (*pusLastEncryptedPartLen);
	}
	in.pusLastEncryptedPartLen = (void*) pusLastEncryptedPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_EncryptFinal_Param *out = r_ck_c_encryptfinal_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_EncryptFinal.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pLastEncryptedPart.pLastEncryptedPart_val);
	in.pLastEncryptedPart.pLastEncryptedPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pLastEncryptedPart.pLastEncryptedPart_len != 0) {
		memcpy(pLastEncryptedPart, out->pLastEncryptedPart.pLastEncryptedPart_val, sizeof(char) * out->pLastEncryptedPart.pLastEncryptedPart_len);
	}
	if (pusLastEncryptedPartLen != NULL && out->pusLastEncryptedPartLen != NULL) {
		memcpy(pusLastEncryptedPartLen, out->pusLastEncryptedPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DecryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_DecryptInit\n");
	fflush(stdout);
	#endif
	R_CK_C_DecryptInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_DecryptInit_Param *out = r_ck_c_decryptinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DecryptInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Decrypt(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedData, CK_ULONG usEncryptedDataLen, CK_BYTE_PTR pData, CK_ULONG_PTR pusDataLen) {
	#ifdef DEBUG
	printf("CK_C_Decrypt\n");
	fflush(stdout);
	#endif
	R_CK_C_Decrypt_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pEncryptedData == NULL) {
		in.pEncryptedData.pEncryptedData_val = NULL;
		in.pEncryptedData.pEncryptedData_len = 0;
	}
	else {
		in.pEncryptedData.pEncryptedData_val = malloc(sizeof(REMOTE_CK_BYTE) * usEncryptedDataLen);
		memcpy(in.pEncryptedData.pEncryptedData_val, pEncryptedData, sizeof(CK_BYTE) * usEncryptedDataLen);
		in.pEncryptedData.pEncryptedData_len = usEncryptedDataLen;
	}
	in.usEncryptedDataLen = usEncryptedDataLen;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusDataLen));
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * (*pusDataLen));
		in.pData.pData_len = (*pusDataLen);
	}
	in.pusDataLen = (void*) pusDataLen;
	// End Wrapping
	//Remote calling
	R_CK_C_Decrypt_Param *out = r_ck_c_decrypt_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Decrypt.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pEncryptedData.pEncryptedData_val);
	in.pEncryptedData.pEncryptedData_val = NULL;
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pData.pData_len != 0) {
		memcpy(pData, out->pData.pData_val, sizeof(char) * out->pData.pData_len);
	}
	if (pusDataLen != NULL && out->pusDataLen != NULL) {
		memcpy(pusDataLen, out->pusDataLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DecryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart, CK_ULONG usEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pusPartLen) {
	#ifdef DEBUG
	printf("CK_C_DecryptUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_DecryptUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pEncryptedPart == NULL) {
		in.pEncryptedPart.pEncryptedPart_val = NULL;
		in.pEncryptedPart.pEncryptedPart_len = 0;
	}
	else {
		in.pEncryptedPart.pEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * usEncryptedPartLen);
		memcpy(in.pEncryptedPart.pEncryptedPart_val, pEncryptedPart, sizeof(CK_BYTE) * usEncryptedPartLen);
		in.pEncryptedPart.pEncryptedPart_len = usEncryptedPartLen;
	}
	in.usEncryptedPartLen = usEncryptedPartLen;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusPartLen));
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * (*pusPartLen));
		in.pPart.pPart_len = (*pusPartLen);
	}
	in.pusPartLen = (void*) pusPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DecryptUpdate_Param *out = r_ck_c_decryptupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DecryptUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pEncryptedPart.pEncryptedPart_val);
	in.pEncryptedPart.pEncryptedPart_val = NULL;
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pPart.pPart_len != 0) {
		memcpy(pPart, out->pPart.pPart_val, sizeof(char) * out->pPart.pPart_len);
	}
	if (pusPartLen != NULL && out->pusPartLen != NULL) {
		memcpy(pusPartLen, out->pusPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DecryptFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pLastPart, CK_ULONG_PTR pusLastPartLen) {
	#ifdef DEBUG
	printf("CK_C_DecryptFinal\n");
	fflush(stdout);
	#endif
	R_CK_C_DecryptFinal_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pLastPart == NULL) {
		in.pLastPart.pLastPart_val = NULL;
		in.pLastPart.pLastPart_len = 0;
	}
	else {
		in.pLastPart.pLastPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusLastPartLen));
		memcpy(in.pLastPart.pLastPart_val, pLastPart, sizeof(CK_BYTE) * (*pusLastPartLen));
		in.pLastPart.pLastPart_len = (*pusLastPartLen);
	}
	in.pusLastPartLen = (void*) pusLastPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DecryptFinal_Param *out = r_ck_c_decryptfinal_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DecryptFinal.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pLastPart.pLastPart_val);
	in.pLastPart.pLastPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pLastPart.pLastPart_len != 0) {
		memcpy(pLastPart, out->pLastPart.pLastPart_val, sizeof(char) * out->pLastPart.pLastPart_len);
	}
	if (pusLastPartLen != NULL && out->pusLastPartLen != NULL) {
		memcpy(pusLastPartLen, out->pusLastPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DigestInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism) {
	#ifdef DEBUG
	printf("CK_C_DigestInit\n");
	fflush(stdout);
	#endif
	R_CK_C_DigestInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DigestInit_Param *out = r_ck_c_digestinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DigestInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Digest(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG usDataLen, CK_BYTE_PTR pDigest, CK_ULONG_PTR pusDigestLen) {
	#ifdef DEBUG
	printf("CK_C_Digest\n");
	fflush(stdout);
	#endif
	R_CK_C_Digest_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * usDataLen);
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * usDataLen);
		in.pData.pData_len = usDataLen;
	}
	in.usDataLen = usDataLen;
	if (pDigest == NULL) {
		in.pDigest.pDigest_val = NULL;
		in.pDigest.pDigest_len = 0;
	}
	else {
		in.pDigest.pDigest_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusDigestLen));
		memcpy(in.pDigest.pDigest_val, pDigest, sizeof(CK_BYTE) * (*pusDigestLen));
		in.pDigest.pDigest_len = (*pusDigestLen);
	}
	in.pusDigestLen = (void*) pusDigestLen;
	// End Wrapping
	//Remote calling
	R_CK_C_Digest_Param *out = r_ck_c_digest_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Digest.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	free(in.pDigest.pDigest_val);
	in.pDigest.pDigest_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pDigest.pDigest_len != 0) {
		memcpy(pDigest, out->pDigest.pDigest_val, sizeof(char) * out->pDigest.pDigest_len);
	}
	if (pusDigestLen != NULL && out->pusDigestLen != NULL) {
		memcpy(pusDigestLen, out->pusDigestLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, CK_ULONG usPartLen) {
	#ifdef DEBUG
	printf("CK_C_DigestUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_DigestUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * usPartLen);
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * usPartLen);
		in.pPart.pPart_len = usPartLen;
	}
	in.usPartLen = usPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DigestUpdate_Param *out = r_ck_c_digestupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DigestUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DigestKey(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_DigestKey\n");
	fflush(stdout);
	#endif
	R_CK_C_DigestKey_Param in;
	// Wrapping
	in.hSession = hSession;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_DigestKey_Param *out = r_ck_c_digestkey_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DigestKey.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DigestFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pDigest, CK_ULONG_PTR pusDigestLen) {
	#ifdef DEBUG
	printf("CK_C_DigestFinal\n");
	fflush(stdout);
	#endif
	R_CK_C_DigestFinal_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pDigest == NULL) {
		in.pDigest.pDigest_val = NULL;
		in.pDigest.pDigest_len = 0;
	}
	else {
		in.pDigest.pDigest_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusDigestLen));
		memcpy(in.pDigest.pDigest_val, pDigest, sizeof(CK_BYTE) * (*pusDigestLen));
		in.pDigest.pDigest_len = (*pusDigestLen);
	}
	in.pusDigestLen = (void*) pusDigestLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DigestFinal_Param *out = r_ck_c_digestfinal_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DigestFinal.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pDigest.pDigest_val);
	in.pDigest.pDigest_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pDigest.pDigest_len != 0) {
		memcpy(pDigest, out->pDigest.pDigest_val, sizeof(char) * out->pDigest.pDigest_len);
	}
	if (pusDigestLen != NULL && out->pusDigestLen != NULL) {
		memcpy(pusDigestLen, out->pusDigestLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SignInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_SignInit\n");
	fflush(stdout);
	#endif
	R_CK_C_SignInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_SignInit_Param *out = r_ck_c_signinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SignInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Sign(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG usDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pusSignatureLen) {
	#ifdef DEBUG
	printf("CK_C_Sign\n");
	fflush(stdout);
	#endif
	R_CK_C_Sign_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * usDataLen);
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * usDataLen);
		in.pData.pData_len = usDataLen;
	}
	in.usDataLen = usDataLen;
	if (pSignature == NULL) {
		in.pSignature.pSignature_val = NULL;
		in.pSignature.pSignature_len = 0;
	}
	else {
		in.pSignature.pSignature_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusSignatureLen));
		memcpy(in.pSignature.pSignature_val, pSignature, sizeof(CK_BYTE) * (*pusSignatureLen));
		in.pSignature.pSignature_len = (*pusSignatureLen);
	}
	in.pusSignatureLen = (void*) pusSignatureLen;
	// End Wrapping
	//Remote calling
	R_CK_C_Sign_Param *out = r_ck_c_sign_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Sign.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	free(in.pSignature.pSignature_val);
	in.pSignature.pSignature_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pSignature.pSignature_len != 0) {
		memcpy(pSignature, out->pSignature.pSignature_val, sizeof(char) * out->pSignature.pSignature_len);
	}
	if (pusSignatureLen != NULL && out->pusSignatureLen != NULL) {
		memcpy(pusSignatureLen, out->pusSignatureLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SignUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, CK_ULONG usPartLen) {
	#ifdef DEBUG
	printf("CK_C_SignUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_SignUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * usPartLen);
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * usPartLen);
		in.pPart.pPart_len = usPartLen;
	}
	in.usPartLen = usPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_SignUpdate_Param *out = r_ck_c_signupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SignUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SignFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature, CK_ULONG_PTR pusSignatureLen) {
	#ifdef DEBUG
	printf("CK_C_SignFinal\n");
	fflush(stdout);
	#endif
	R_CK_C_SignFinal_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pSignature == NULL) {
		in.pSignature.pSignature_val = NULL;
		in.pSignature.pSignature_len = 0;
	}
	else {
		in.pSignature.pSignature_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusSignatureLen));
		memcpy(in.pSignature.pSignature_val, pSignature, sizeof(CK_BYTE) * (*pusSignatureLen));
		in.pSignature.pSignature_len = (*pusSignatureLen);
	}
	in.pusSignatureLen = (void*) pusSignatureLen;
	// End Wrapping
	//Remote calling
	R_CK_C_SignFinal_Param *out = r_ck_c_signfinal_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SignFinal.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pSignature.pSignature_val);
	in.pSignature.pSignature_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pSignature.pSignature_len != 0) {
		memcpy(pSignature, out->pSignature.pSignature_val, sizeof(char) * out->pSignature.pSignature_len);
	}
	if (pusSignatureLen != NULL && out->pusSignatureLen != NULL) {
		memcpy(pusSignatureLen, out->pusSignatureLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SignRecoverInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_SignRecoverInit\n");
	fflush(stdout);
	#endif
	R_CK_C_SignRecoverInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_SignRecoverInit_Param *out = r_ck_c_signrecoverinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SignRecoverInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SignRecover(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG usDataLen, CK_BYTE_PTR pSignature, CK_ULONG_PTR pusSignatureLen) {
	#ifdef DEBUG
	printf("CK_C_SignRecover\n");
	fflush(stdout);
	#endif
	R_CK_C_SignRecover_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * usDataLen);
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * usDataLen);
		in.pData.pData_len = usDataLen;
	}
	in.usDataLen = usDataLen;
	if (pSignature == NULL) {
		in.pSignature.pSignature_val = NULL;
		in.pSignature.pSignature_len = 0;
	}
	else {
		in.pSignature.pSignature_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusSignatureLen));
		memcpy(in.pSignature.pSignature_val, pSignature, sizeof(CK_BYTE) * (*pusSignatureLen));
		in.pSignature.pSignature_len = (*pusSignatureLen);
	}
	in.pusSignatureLen = (void*) pusSignatureLen;
	// End Wrapping
	//Remote calling
	R_CK_C_SignRecover_Param *out = r_ck_c_signrecover_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SignRecover.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	free(in.pSignature.pSignature_val);
	in.pSignature.pSignature_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pSignature.pSignature_len != 0) {
		memcpy(pSignature, out->pSignature.pSignature_val, sizeof(char) * out->pSignature.pSignature_len);
	}
	if (pusSignatureLen != NULL && out->pusSignatureLen != NULL) {
		memcpy(pusSignatureLen, out->pusSignatureLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_VerifyInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_VerifyInit\n");
	fflush(stdout);
	#endif
	R_CK_C_VerifyInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_VerifyInit_Param *out = r_ck_c_verifyinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_VerifyInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_Verify(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pData, CK_ULONG usDataLen, CK_BYTE_PTR pSignature, CK_ULONG usSignatureLen) {
	#ifdef DEBUG
	printf("CK_C_Verify\n");
	fflush(stdout);
	#endif
	R_CK_C_Verify_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * usDataLen);
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * usDataLen);
		in.pData.pData_len = usDataLen;
	}
	in.usDataLen = usDataLen;
	if (pSignature == NULL) {
		in.pSignature.pSignature_val = NULL;
		in.pSignature.pSignature_len = 0;
	}
	else {
		in.pSignature.pSignature_val = malloc(sizeof(REMOTE_CK_BYTE) * usSignatureLen);
		memcpy(in.pSignature.pSignature_val, pSignature, sizeof(CK_BYTE) * usSignatureLen);
		in.pSignature.pSignature_len = usSignatureLen;
	}
	in.usSignatureLen = usSignatureLen;
	// End Wrapping
	//Remote calling
	R_CK_C_Verify_Param *out = r_ck_c_verify_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_Verify.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	free(in.pSignature.pSignature_val);
	in.pSignature.pSignature_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_VerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, CK_ULONG usPartLen) {
	#ifdef DEBUG
	printf("CK_C_VerifyUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_VerifyUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * usPartLen);
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * usPartLen);
		in.pPart.pPart_len = usPartLen;
	}
	in.usPartLen = usPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_VerifyUpdate_Param *out = r_ck_c_verifyupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_VerifyUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_VerifyFinal(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature, CK_ULONG usSignatureLen) {
	#ifdef DEBUG
	printf("CK_C_VerifyFinal\n");
	fflush(stdout);
	#endif
	R_CK_C_VerifyFinal_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pSignature == NULL) {
		in.pSignature.pSignature_val = NULL;
		in.pSignature.pSignature_len = 0;
	}
	else {
		in.pSignature.pSignature_val = malloc(sizeof(REMOTE_CK_BYTE) * usSignatureLen);
		memcpy(in.pSignature.pSignature_val, pSignature, sizeof(CK_BYTE) * usSignatureLen);
		in.pSignature.pSignature_len = usSignatureLen;
	}
	in.usSignatureLen = usSignatureLen;
	// End Wrapping
	//Remote calling
	R_CK_C_VerifyFinal_Param *out = r_ck_c_verifyfinal_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_VerifyFinal.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pSignature.pSignature_val);
	in.pSignature.pSignature_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_VerifyRecoverInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hKey) {
	#ifdef DEBUG
	printf("CK_C_VerifyRecoverInit\n");
	fflush(stdout);
	#endif
	R_CK_C_VerifyRecoverInit_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hKey = hKey;
	// End Wrapping
	//Remote calling
	R_CK_C_VerifyRecoverInit_Param *out = r_ck_c_verifyrecoverinit_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_VerifyRecoverInit.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_VerifyRecover(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature, CK_ULONG usSignatureLen, CK_BYTE_PTR pData, CK_ULONG_PTR pusDataLen) {
	#ifdef DEBUG
	printf("CK_C_VerifyRecover\n");
	fflush(stdout);
	#endif
	R_CK_C_VerifyRecover_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pSignature == NULL) {
		in.pSignature.pSignature_val = NULL;
		in.pSignature.pSignature_len = 0;
	}
	else {
		in.pSignature.pSignature_val = malloc(sizeof(REMOTE_CK_BYTE) * usSignatureLen);
		memcpy(in.pSignature.pSignature_val, pSignature, sizeof(CK_BYTE) * usSignatureLen);
		in.pSignature.pSignature_len = usSignatureLen;
	}
	in.usSignatureLen = usSignatureLen;
	if (pData == NULL) {
		in.pData.pData_val = NULL;
		in.pData.pData_len = 0;
	}
	else {
		in.pData.pData_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusDataLen));
		memcpy(in.pData.pData_val, pData, sizeof(CK_BYTE) * (*pusDataLen));
		in.pData.pData_len = (*pusDataLen);
	}
	in.pusDataLen = (void*) pusDataLen;
	// End Wrapping
	//Remote calling
	R_CK_C_VerifyRecover_Param *out = r_ck_c_verifyrecover_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_VerifyRecover.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pSignature.pSignature_val);
	in.pSignature.pSignature_val = NULL;
	free(in.pData.pData_val);
	in.pData.pData_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pData.pData_len != 0) {
		memcpy(pData, out->pData.pData_val, sizeof(char) * out->pData.pData_len);
	}
	if (pusDataLen != NULL && out->pusDataLen != NULL) {
		memcpy(pusDataLen, out->pusDataLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DigestEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart, CK_ULONG_PTR pulEncryptedPartLen) {
	#ifdef DEBUG
	printf("CK_C_DigestEncryptUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_DigestEncryptUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * ulPartLen);
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * ulPartLen);
		in.pPart.pPart_len = ulPartLen;
	}
	in.ulPartLen = ulPartLen;
	if (pEncryptedPart == NULL) {
		in.pEncryptedPart.pEncryptedPart_val = NULL;
		in.pEncryptedPart.pEncryptedPart_len = 0;
	}
	else {
		in.pEncryptedPart.pEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pulEncryptedPartLen));
		memcpy(in.pEncryptedPart.pEncryptedPart_val, pEncryptedPart, sizeof(CK_BYTE) * (*pulEncryptedPartLen));
		in.pEncryptedPart.pEncryptedPart_len = (*pulEncryptedPartLen);
	}
	in.pulEncryptedPartLen = (void*) pulEncryptedPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DigestEncryptUpdate_Param *out = r_ck_c_digestencryptupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DigestEncryptUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	free(in.pEncryptedPart.pEncryptedPart_val);
	in.pEncryptedPart.pEncryptedPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pEncryptedPart.pEncryptedPart_len != 0) {
		memcpy(pEncryptedPart, out->pEncryptedPart.pEncryptedPart_val, sizeof(char) * out->pEncryptedPart.pEncryptedPart_len);
	}
	if (pulEncryptedPartLen != NULL && out->pulEncryptedPartLen != NULL) {
		memcpy(pulEncryptedPartLen, out->pulEncryptedPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DecryptDigestUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart, CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen) {
	#ifdef DEBUG
	printf("CK_C_DecryptDigestUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_DecryptDigestUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pEncryptedPart == NULL) {
		in.pEncryptedPart.pEncryptedPart_val = NULL;
		in.pEncryptedPart.pEncryptedPart_len = 0;
	}
	else {
		in.pEncryptedPart.pEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * ulEncryptedPartLen);
		memcpy(in.pEncryptedPart.pEncryptedPart_val, pEncryptedPart, sizeof(CK_BYTE) * ulEncryptedPartLen);
		in.pEncryptedPart.pEncryptedPart_len = ulEncryptedPartLen;
	}
	in.ulEncryptedPartLen = ulEncryptedPartLen;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pulPartLen));
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * (*pulPartLen));
		in.pPart.pPart_len = (*pulPartLen);
	}
	in.pulPartLen = (void*) pulPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DecryptDigestUpdate_Param *out = r_ck_c_decryptdigestupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DecryptDigestUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pEncryptedPart.pEncryptedPart_val);
	in.pEncryptedPart.pEncryptedPart_val = NULL;
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pPart.pPart_len != 0) {
		memcpy(pPart, out->pPart.pPart_val, sizeof(char) * out->pPart.pPart_len);
	}
	if (pulPartLen != NULL && out->pulPartLen != NULL) {
		memcpy(pulPartLen, out->pulPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SignEncryptUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pPart, CK_ULONG ulPartLen, CK_BYTE_PTR pEncryptedPart, CK_ULONG_PTR pulEncryptedPartLen) {
	#ifdef DEBUG
	printf("CK_C_SignEncryptUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_SignEncryptUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * ulPartLen);
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * ulPartLen);
		in.pPart.pPart_len = ulPartLen;
	}
	in.ulPartLen = ulPartLen;
	if (pEncryptedPart == NULL) {
		in.pEncryptedPart.pEncryptedPart_val = NULL;
		in.pEncryptedPart.pEncryptedPart_len = 0;
	}
	else {
		in.pEncryptedPart.pEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pulEncryptedPartLen));
		memcpy(in.pEncryptedPart.pEncryptedPart_val, pEncryptedPart, sizeof(CK_BYTE) * (*pulEncryptedPartLen));
		in.pEncryptedPart.pEncryptedPart_len = (*pulEncryptedPartLen);
	}
	in.pulEncryptedPartLen = (void*) pulEncryptedPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_SignEncryptUpdate_Param *out = r_ck_c_signencryptupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SignEncryptUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	free(in.pEncryptedPart.pEncryptedPart_val);
	in.pEncryptedPart.pEncryptedPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pEncryptedPart.pEncryptedPart_len != 0) {
		memcpy(pEncryptedPart, out->pEncryptedPart.pEncryptedPart_val, sizeof(char) * out->pEncryptedPart.pEncryptedPart_len);
	}
	if (pulEncryptedPartLen != NULL && out->pulEncryptedPartLen != NULL) {
		memcpy(pulEncryptedPartLen, out->pulEncryptedPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DecryptVerifyUpdate(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pEncryptedPart, CK_ULONG ulEncryptedPartLen, CK_BYTE_PTR pPart, CK_ULONG_PTR pulPartLen) {
	#ifdef DEBUG
	printf("CK_C_DecryptVerifyUpdate\n");
	fflush(stdout);
	#endif
	R_CK_C_DecryptVerifyUpdate_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pEncryptedPart == NULL) {
		in.pEncryptedPart.pEncryptedPart_val = NULL;
		in.pEncryptedPart.pEncryptedPart_len = 0;
	}
	else {
		in.pEncryptedPart.pEncryptedPart_val = malloc(sizeof(REMOTE_CK_BYTE) * ulEncryptedPartLen);
		memcpy(in.pEncryptedPart.pEncryptedPart_val, pEncryptedPart, sizeof(CK_BYTE) * ulEncryptedPartLen);
		in.pEncryptedPart.pEncryptedPart_len = ulEncryptedPartLen;
	}
	in.ulEncryptedPartLen = ulEncryptedPartLen;
	if (pPart == NULL) {
		in.pPart.pPart_val = NULL;
		in.pPart.pPart_len = 0;
	}
	else {
		in.pPart.pPart_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pulPartLen));
		memcpy(in.pPart.pPart_val, pPart, sizeof(CK_BYTE) * (*pulPartLen));
		in.pPart.pPart_len = (*pulPartLen);
	}
	in.pulPartLen = (void*) pulPartLen;
	// End Wrapping
	//Remote calling
	R_CK_C_DecryptVerifyUpdate_Param *out = r_ck_c_decryptverifyupdate_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DecryptVerifyUpdate.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pEncryptedPart.pEncryptedPart_val);
	in.pEncryptedPart.pEncryptedPart_val = NULL;
	free(in.pPart.pPart_val);
	in.pPart.pPart_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pPart.pPart_len != 0) {
		memcpy(pPart, out->pPart.pPart_val, sizeof(char) * out->pPart.pPart_len);
	}
	if (pulPartLen != NULL && out->pulPartLen != NULL) {
		memcpy(pulPartLen, out->pulPartLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GenerateKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usCount, CK_OBJECT_HANDLE_PTR phKey) {
	#ifdef DEBUG
	printf("CK_C_GenerateKey\n");
	fflush(stdout);
	#endif
	R_CK_C_GenerateKey_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usCount);
		in.pTemplate.pTemplate_len = usCount;
	}
	in.usCount = usCount;
	in.phKey = (void*) phKey;
	// End Wrapping
	//Remote calling
	R_CK_C_GenerateKey_Param *out = r_ck_c_generatekey_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GenerateKey.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (phKey != NULL && out->phKey != NULL) {
		memcpy(phKey, out->phKey, sizeof(CK_OBJECT_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GenerateKeyPair(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_ATTRIBUTE_PTR pPublicKeyTemplate, CK_ULONG usPublicKeyAttributeCount, CK_ATTRIBUTE_PTR pPrivateKeyTemplate, CK_ULONG usPrivateKeyAttributeCount, CK_OBJECT_HANDLE_PTR phPrivateKey, CK_OBJECT_HANDLE_PTR phPublicKey) {
	#ifdef DEBUG
	printf("CK_C_GenerateKeyPair\n");
	fflush(stdout);
	#endif
	R_CK_C_GenerateKeyPair_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	if (pPublicKeyTemplate == NULL) {
		in.pPublicKeyTemplate.pPublicKeyTemplate_val = NULL;
		in.pPublicKeyTemplate.pPublicKeyTemplate_len = 0;
	}
	else {
		in.pPublicKeyTemplate.pPublicKeyTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usPublicKeyAttributeCount);
		CK_ATTRIBUTE *pLocal = pPublicKeyTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pPublicKeyTemplate.pPublicKeyTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usPublicKeyAttributeCount);
		in.pPublicKeyTemplate.pPublicKeyTemplate_len = usPublicKeyAttributeCount;
	}
	in.usPublicKeyAttributeCount = usPublicKeyAttributeCount;
	if (pPrivateKeyTemplate == NULL) {
		in.pPrivateKeyTemplate.pPrivateKeyTemplate_val = NULL;
		in.pPrivateKeyTemplate.pPrivateKeyTemplate_len = 0;
	}
	else {
		in.pPrivateKeyTemplate.pPrivateKeyTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usPrivateKeyAttributeCount);
		CK_ATTRIBUTE *pLocal = pPrivateKeyTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pPrivateKeyTemplate.pPrivateKeyTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usPrivateKeyAttributeCount);
		in.pPrivateKeyTemplate.pPrivateKeyTemplate_len = usPrivateKeyAttributeCount;
	}
	in.usPrivateKeyAttributeCount = usPrivateKeyAttributeCount;
	in.phPrivateKey = (void*) phPrivateKey;
	in.phPublicKey = (void*) phPublicKey;
	// End Wrapping
	//Remote calling
	R_CK_C_GenerateKeyPair_Param *out = r_ck_c_generatekeypair_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GenerateKeyPair.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	if (pPublicKeyTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pPublicKeyTemplate.pPublicKeyTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usPublicKeyAttributeCount);
	}
	free(in.pPublicKeyTemplate.pPublicKeyTemplate_val);
	in.pPublicKeyTemplate.pPublicKeyTemplate_val = NULL;
	if (pPrivateKeyTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pPrivateKeyTemplate.pPrivateKeyTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usPrivateKeyAttributeCount);
	}
	free(in.pPrivateKeyTemplate.pPrivateKeyTemplate_val);
	in.pPrivateKeyTemplate.pPrivateKeyTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (phPrivateKey != NULL && out->phPrivateKey != NULL) {
		memcpy(phPrivateKey, out->phPrivateKey, sizeof(CK_OBJECT_HANDLE));
	}
	if (phPublicKey != NULL && out->phPublicKey != NULL) {
		memcpy(phPublicKey, out->phPublicKey, sizeof(CK_OBJECT_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_WrapKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hWrappingKey, CK_OBJECT_HANDLE hKey, CK_BYTE_PTR pWrappedKey, CK_ULONG_PTR pusWrappedKeyLen) {
	#ifdef DEBUG
	printf("CK_C_WrapKey\n");
	fflush(stdout);
	#endif
	R_CK_C_WrapKey_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hWrappingKey = hWrappingKey;
	in.hKey = hKey;
	if (pWrappedKey == NULL) {
		in.pWrappedKey.pWrappedKey_val = NULL;
		in.pWrappedKey.pWrappedKey_len = 0;
	}
	else {
		in.pWrappedKey.pWrappedKey_val = malloc(sizeof(REMOTE_CK_BYTE) * (*pusWrappedKeyLen));
		memcpy(in.pWrappedKey.pWrappedKey_val, pWrappedKey, sizeof(CK_BYTE) * (*pusWrappedKeyLen));
		in.pWrappedKey.pWrappedKey_len = (*pusWrappedKeyLen);
	}
	in.pusWrappedKeyLen = (void*) pusWrappedKeyLen;
	// End Wrapping
	//Remote calling
	R_CK_C_WrapKey_Param *out = r_ck_c_wrapkey_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_WrapKey.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	free(in.pWrappedKey.pWrappedKey_val);
	in.pWrappedKey.pWrappedKey_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pWrappedKey.pWrappedKey_len != 0) {
		memcpy(pWrappedKey, out->pWrappedKey.pWrappedKey_val, sizeof(char) * out->pWrappedKey.pWrappedKey_len);
	}
	if (pusWrappedKeyLen != NULL && out->pusWrappedKeyLen != NULL) {
		memcpy(pusWrappedKeyLen, out->pusWrappedKeyLen, sizeof(CK_ULONG));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_UnwrapKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hUnwrappingKey, CK_BYTE_PTR pWrappedKey, CK_ULONG usWrappedKeyLen, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usAttributeCount, CK_OBJECT_HANDLE_PTR phKey) {
	#ifdef DEBUG
	printf("CK_C_UnwrapKey\n");
	fflush(stdout);
	#endif
	R_CK_C_UnwrapKey_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hUnwrappingKey = hUnwrappingKey;
	if (pWrappedKey == NULL) {
		in.pWrappedKey.pWrappedKey_val = NULL;
		in.pWrappedKey.pWrappedKey_len = 0;
	}
	else {
		in.pWrappedKey.pWrappedKey_val = malloc(sizeof(REMOTE_CK_BYTE) * usWrappedKeyLen);
		memcpy(in.pWrappedKey.pWrappedKey_val, pWrappedKey, sizeof(CK_BYTE) * usWrappedKeyLen);
		in.pWrappedKey.pWrappedKey_len = usWrappedKeyLen;
	}
	in.usWrappedKeyLen = usWrappedKeyLen;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usAttributeCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usAttributeCount);
		in.pTemplate.pTemplate_len = usAttributeCount;
	}
	in.usAttributeCount = usAttributeCount;
	in.phKey = (void*) phKey;
	// End Wrapping
	//Remote calling
	R_CK_C_UnwrapKey_Param *out = r_ck_c_unwrapkey_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_UnwrapKey.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	free(in.pWrappedKey.pWrappedKey_val);
	in.pWrappedKey.pWrappedKey_val = NULL;
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usAttributeCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (phKey != NULL && out->phKey != NULL) {
		memcpy(phKey, out->phKey, sizeof(CK_OBJECT_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_DeriveKey(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism, CK_OBJECT_HANDLE hBaseKey, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG usAttributeCount, CK_OBJECT_HANDLE_PTR phKey) {
	#ifdef DEBUG
	printf("CK_C_DeriveKey\n");
	fflush(stdout);
	#endif
	R_CK_C_DeriveKey_Param in;
	// Wrapping
	in.hSession = hSession;
	in.pMechanism = malloc(sizeof(REMOTE_CK_MECHANISM));
	in.pMechanism->mechanism = pMechanism->mechanism;
	if (pMechanism->pParameter == NULL) {
		in.pMechanism->pParameter.pParameter_val = NULL;
		in.pMechanism->pParameter.pParameter_len = 0;
	}
	else {
		in.pMechanism->pParameter.pParameter_val = malloc(sizeof(REMOTE_CK_VOID_PTR) * pMechanism->ulParameterLen);
		memcpy(in.pMechanism->pParameter.pParameter_val, pMechanism->pParameter, sizeof(CK_VOID_PTR) * pMechanism->ulParameterLen);
		in.pMechanism->pParameter.pParameter_len = pMechanism->ulParameterLen;
	}
	in.pMechanism->ulParameterLen = pMechanism->ulParameterLen;
	in.hBaseKey = hBaseKey;
	if (pTemplate == NULL) {
		in.pTemplate.pTemplate_val = NULL;
		in.pTemplate.pTemplate_len = 0;
	}
	else {
		in.pTemplate.pTemplate_val = malloc(sizeof(REMOTE_CK_ATTRIBUTE) * usAttributeCount);
		CK_ATTRIBUTE *pLocal = pTemplate;
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		wrap_CK_ATTRIBUTE(pLocal, pRemote, &usAttributeCount);
		in.pTemplate.pTemplate_len = usAttributeCount;
	}
	in.usAttributeCount = usAttributeCount;
	in.phKey = (void*) phKey;
	// End Wrapping
	//Remote calling
	R_CK_C_DeriveKey_Param *out = r_ck_c_derivekey_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_DeriveKey.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	if (in.pMechanism != NULL) {
		free(in.pMechanism->pParameter.pParameter_val);
		in.pMechanism->pParameter.pParameter_val = NULL;
	}
	free(in.pMechanism);
	in.pMechanism = NULL;
	if (pTemplate != NULL) {
		REMOTE_CK_ATTRIBUTE *pRemote = in.pTemplate.pTemplate_val;
		free_wrap_CK_ATTRIBUTE(pRemote, (int) usAttributeCount);
	}
	free(in.pTemplate.pTemplate_val);
	in.pTemplate.pTemplate_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (phKey != NULL && out->phKey != NULL) {
		memcpy(phKey, out->phKey, sizeof(CK_OBJECT_HANDLE));
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_SeedRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSeed, CK_ULONG usSeedLen) {
	#ifdef DEBUG
	printf("CK_C_SeedRandom\n");
	fflush(stdout);
	#endif
	R_CK_C_SeedRandom_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pSeed == NULL) {
		in.pSeed.pSeed_val = NULL;
		in.pSeed.pSeed_len = 0;
	}
	else {
		in.pSeed.pSeed_val = malloc(sizeof(REMOTE_CK_BYTE) * usSeedLen);
		memcpy(in.pSeed.pSeed_val, pSeed, sizeof(CK_BYTE) * usSeedLen);
		in.pSeed.pSeed_len = usSeedLen;
	}
	in.usSeedLen = usSeedLen;
	// End Wrapping
	//Remote calling
	R_CK_C_SeedRandom_Param *out = r_ck_c_seedrandom_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_SeedRandom.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pSeed.pSeed_val);
	in.pSeed.pSeed_val = NULL;
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GenerateRandom(CK_SESSION_HANDLE hSession, CK_BYTE_PTR pRandomData, CK_ULONG usRandomLen) {
	#ifdef DEBUG
	printf("CK_C_GenerateRandom\n");
	fflush(stdout);
	#endif
	R_CK_C_GenerateRandom_Param in;
	// Wrapping
	in.hSession = hSession;
	if (pRandomData == NULL) {
		in.pRandomData.pRandomData_val = NULL;
		in.pRandomData.pRandomData_len = 0;
	}
	else {
		in.pRandomData.pRandomData_val = malloc(sizeof(REMOTE_CK_BYTE) * usRandomLen);
		memcpy(in.pRandomData.pRandomData_val, pRandomData, sizeof(CK_BYTE) * usRandomLen);
		in.pRandomData.pRandomData_len = usRandomLen;
	}
	in.usRandomLen = usRandomLen;
	// End Wrapping
	//Remote calling
	R_CK_C_GenerateRandom_Param *out = r_ck_c_generaterandom_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GenerateRandom.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	free(in.pRandomData.pRandomData_val);
	in.pRandomData.pRandomData_val = NULL;
	// End Free Wrapping
	// Unwrapping
	if (out->pRandomData.pRandomData_len != 0) {
		memcpy(pRandomData, out->pRandomData.pRandomData_val, sizeof(char) * out->pRandomData.pRandomData_len);
	}
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_GetFunctionStatus(CK_SESSION_HANDLE hSession) {
	#ifdef DEBUG
	printf("CK_C_GetFunctionStatus\n");
	fflush(stdout);
	#endif
	R_CK_C_GetFunctionStatus_Param in;
	// Wrapping
	in.hSession = hSession;
	// End Wrapping
	//Remote calling
	R_CK_C_GetFunctionStatus_Param *out = r_ck_c_getfunctionstatus_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_GetFunctionStatus.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_CancelFunction(CK_SESSION_HANDLE hSession) {
	#ifdef DEBUG
	printf("CK_C_CancelFunction\n");
	fflush(stdout);
	#endif
	R_CK_C_CancelFunction_Param in;
	// Wrapping
	in.hSession = hSession;
	// End Wrapping
	//Remote calling
	R_CK_C_CancelFunction_Param *out = r_ck_c_cancelfunction_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_CancelFunction.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	// End Unwrapping
	return out->return_value;
}


CK_RV CK_C_WaitForSlotEvent(CK_FLAGS flags, CK_SLOT_ID_PTR pSlot, CK_VOID_PTR pReserved) {
	#ifdef DEBUG
	printf("CK_C_WaitForSlotEvent\n");
	fflush(stdout);
	#endif
	R_CK_C_WaitForSlotEvent_Param in;
	// Wrapping
	in.flags = flags;
	in.pSlot = (void*) pSlot;
	in.pReserved = (void*) pReserved;
	// End Wrapping
	//Remote calling
	R_CK_C_WaitForSlotEvent_Param *out = r_ck_c_waitforslotevent_1(&in,cl);
	if (out == NULL) {
		char *str_error = "Error during remote call CK_C_WaitForSlotEvent.";
		clnt_pcreateerror(str_error);
		return CKR_GENERAL_ERROR;
	}
	// Free Wrapping
	// End Free Wrapping
	// Unwrapping
	if (pSlot != NULL && out->pSlot != NULL) {
		memcpy(pSlot, out->pSlot, sizeof(CK_SLOT_ID));
	}
	// End Unwrapping
	return out->return_value;
}


